package com.spider.admin.scaffold.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spider.admin.scaffold.service.ErrorLogService;
import com.spider.admin.scaffold.entity.model.ErrorLog;
import com.spider.admin.scaffold.entity.param.OperationLogQueryParam;
import com.spider.admin.scaffold.mapper.ErrorLogMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author xiong.bo
 * @version 1.0
 * @date 2024/6/3 8:24 下午
 */

@Service
public class ErrorLogServiceImpl extends ServiceImpl<ErrorLogMapper, ErrorLog>
        implements ErrorLogService {


    @Override
    public Page<ErrorLog> selectPage(OperationLogQueryParam queryParam) {
        LambdaQueryWrapper<ErrorLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(queryParam.getUsername()), ErrorLog::getUsername, queryParam.getUsername());
        queryWrapper.like(StringUtils.hasText(queryParam.getAccessPath()), ErrorLog::getAccessPath, queryParam.getAccessPath());
        queryWrapper.orderByDesc(ErrorLog::getCreateTime);
        return this.baseMapper.selectPage(queryParam.buildPage(), queryWrapper);
    }
}
